package cn.xy.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Demo class
 *
 * @author 恣意
 * @date 2016/10/31
 */
@SuppressWarnings({"ALL", "AlibabaUndefineMagicConstant"})
public class HelloServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }

    @SuppressWarnings("AlibabaUndefineMagicConstant")
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String add = null;

        String method = request.getParameter("method");
        if ("add".equals(method)){
            request.getSession().setAttribute("msg","执行了add方法");
        }else //noinspection AlibabaUndefineMagicConstant
            if (("delete").equals(method)){
            request.getSession().setAttribute("msg","执行了delete方法");
        }

        String a =    "";

        request.getRequestDispatcher("/WEB-INF/jsp/hello.jsp").forward(request,response);
    }
}
